<html>
<head><meta charset="utf-8"><title>async drop · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html">async drop</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="176007755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/176007755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#176007755">(Sep 18 2019 at 14:03)</a>:</h4>
<p>Has there been discussion about some kind of async drop? For example, if you have a database connection that does a <code>COMMIT</code> on drop, that might take time. <code>Drop</code> is sync by nature, which might tie up the future.</p>
<p>My guess is that the answer is "create a bespoke method that does the IO work and you can call <code>.await</code> on it"</p>



<a name="176008143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/176008143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#176008143">(Sep 18 2019 at 14:08)</a>:</h4>
<p>Hm, so I feel like I've seen some discussion about this on internals</p>



<a name="176008194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/176008194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#176008194">(Sep 18 2019 at 14:08)</a>:</h4>
<p>But it does seem like you could do something like <code>rt::spawn(commit())</code> and then just exit, though that does mean that you will only find out later that the commit didn't go through</p>



<a name="176008228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/176008228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#176008228">(Sep 18 2019 at 14:09)</a>:</h4>
<p>but that seems similar to e.g. File's Drop not panicking on errors and such</p>



<a name="176008538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/176008538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#176008538">(Sep 18 2019 at 14:12)</a>:</h4>
<p>I agree with the similarity, which is solved by using an explicit call as well (e.g. <code>sync_all</code>)</p>



<a name="176008586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/176008586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#176008586">(Sep 18 2019 at 14:12)</a>:</h4>
<blockquote>
<p>like you could do something like <code>rt::spawn(commit())</code></p>
</blockquote>
<p>Do you mean in the <code>Drop::drop</code> implementation?</p>



<a name="176010647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/176010647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#176010647">(Sep 18 2019 at 14:33)</a>:</h4>
<p>yeah</p>



<a name="176039755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/176039755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#176039755">(Sep 18 2019 at 19:54)</a>:</h4>
<p>We've thought about this a fair bit!</p>



<a name="176039847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/176039847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#176039847">(Sep 18 2019 at 19:55)</a>:</h4>
<p>I've sketched threw the design a few weeks ago and made an interesting realization, which I will record here: the problem with something like <code>async fn drop</code> is that the future it returns can contain additional state beyond <code>&amp;mut Self</code>.</p>



<a name="176039912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/176039912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#176039912">(Sep 18 2019 at 19:56)</a>:</h4>
<p>This means that the futures which call the destructor may, for example, not be <code>Send</code> if you introduce <code>!Send</code> state.</p>



<a name="176039978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/176039978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#176039978">(Sep 18 2019 at 19:56)</a>:</h4>
<p>There's absolutely no way to write the bound for "the future returned by T's async destructor, if it has one, is <code>Send</code>"</p>



<a name="176040051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/176040051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#176040051">(Sep 18 2019 at 19:57)</a>:</h4>
<p><code>T: AsyncDrop implies OutputOf(&lt;T as AsyncDrop&gt;::drop_async): Send</code>, combining several features we don't have, and not pretty</p>



<a name="176040131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/176040131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#176040131">(Sep 18 2019 at 19:58)</a>:</h4>
<p>In the near term, we should probably pursue a poll-based approach: <code>fn poll_drop(self: Pin&lt;&amp;mut Self&gt;) -&gt; Poll&lt;()&gt;</code>. In the long term we could also introduce an async fn version if we feel its needed.</p>



<a name="176040237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/176040237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#176040237">(Sep 18 2019 at 19:59)</a>:</h4>
<p>The poll based approach guarantees that all of the state for the async destructor is contained in the type being destroyed.</p>



<a name="178369811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/178369811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#178369811">(Oct 17 2019 at 10:55)</a>:</h4>
<p>I wrote a blog post about this, and theres now an internals thread: <a href="https://internals.rust-lang.org/t/asynchronous-destructors/11127/16" target="_blank" title="https://internals.rust-lang.org/t/asynchronous-destructors/11127/16">https://internals.rust-lang.org/t/asynchronous-destructors/11127/16</a></p>



<a name="178374521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/178374521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> stko <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#178374521">(Oct 17 2019 at 12:10)</a>:</h4>
<p>The desugaring proposed in internals thread is synchronous:</p>
<div class="codehilite"><pre><span></span>while let Poll::Pending = self.poll_drop_ready(cx) {}
self.drop()
</pre></div>


<p>Shouldn't it be something more along the lines of:</p>
<div class="codehilite"><pre><span></span>poll_fn(self.poll_drop_ready).await;
self.drop()
</pre></div>



<a name="230931463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/230931463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick Walton <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#230931463">(Mar 18 2021 at 20:22)</a>:</h4>
<p>Is there a good place to look for the status of async drop?</p>



<a name="230936890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/230936890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#230936890">(Mar 18 2021 at 21:01)</a>:</h4>
<p><span class="user-mention" data-user-id="384014">@Patrick Walton</span> I think that the most recent proposal was <a href="https://github.com/rust-lang/rfcs/pull/2958">https://github.com/rust-lang/rfcs/pull/2958</a>, and that it is basically 'state of the art', but that there are some concerns. Why do you ask?</p>



<a name="230936929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/230936929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#230936929">(Mar 18 2021 at 21:01)</a>:</h4>
<p>I would encourage you to open an issue or a PR describing what problems you are encountering that motivated this question</p>



<a name="230937102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/230937102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick Walton <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#230937102">(Mar 18 2021 at 21:02)</a>:</h4>
<p>There's no particular problem that motivates it, it's more just curiosity, wanting to understand the history of the async design in Rust better</p>



<a name="230937331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/230937331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick Walton <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#230937331">(Mar 18 2021 at 21:04)</a>:</h4>
<p>Thanks for the pointer :)</p>



<a name="230937347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/230937347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#230937347">(Mar 18 2021 at 21:04)</a>:</h4>
<p>Oh, I have an example of a motivation on this tho ^^</p>



<a name="230937355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/230937355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#230937355">(Mar 18 2021 at 21:04)</a>:</h4>
<p>Fooey. Well, then I encourage you to get folks in FB to participate regardless</p>



<a name="230937361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/230937361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#230937361">(Mar 18 2021 at 21:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Async.20drop/near/230937347">said</a>:</p>
<blockquote>
<p>Oh, I have an example of a motivation on this tho ^^</p>
</blockquote>
<p>now we're talking!</p>



<a name="230937383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/230937383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#230937383">(Mar 18 2021 at 21:04)</a>:</h4>
<p>Where do I write it?</p>



<a name="230937423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/230937423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#230937423">(Mar 18 2021 at 21:05)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> <a href="https://nikomatsakis.github.io/wg-async-foundations/vision/how_to_vision/status_quo.html#tldr">https://nikomatsakis.github.io/wg-async-foundations/vision/how_to_vision/status_quo.html#tldr</a></p>



<a name="230937448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/230937448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#230937448">(Mar 18 2021 at 21:05)</a>:</h4>
<p>probably open an issue is the easiest way to start :)</p>



<a name="230937472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/230937472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#230937472">(Mar 18 2021 at 21:05)</a>:</h4>
<p>the idea would be to describe the problem you are facing now</p>



<a name="230937495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/230937495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#230937495">(Mar 18 2021 at 21:05)</a>:</h4>
<p>(not the <em>solution</em>, that comes later)</p>



<a name="230939203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/230939203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick Walton <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#230939203">(Mar 18 2021 at 21:17)</a>:</h4>
<p>So this grew out of a question of trying to make C++ senders/receivers work well with Rust futures</p>



<a name="230973239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/230973239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick Walton <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#230973239">(Mar 19 2021 at 04:07)</a>:</h4>
<p>Now I know the issue: we want to call APIs that use the C++ equivalent of futures from Rust programs, but C++ futures must be polled to completion (it's undefined behavior to drop them), while Rust futures can be dropped at any time.</p>



<a name="240377958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240377958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240377958">(May 26 2021 at 19:28)</a>:</h4>
<p>I'm confused why we talk so much about <code>AsyncDrop</code> before figuring out what problem it actually solves?</p>



<a name="240378038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378038">(May 26 2021 at 19:28)</a>:</h4>
<p>We know some pretty concrete problems that it solves</p>



<a name="240378074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378074">(May 26 2021 at 19:29)</a>:</h4>
<p>I'm still of the strong opinion that it its a useless endeavour if it doesn't provide any guarantees, and provide just more questions</p>



<a name="240378126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378126">(May 26 2021 at 19:29)</a>:</h4>
<p>that's one opinion</p>



<a name="240378145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378145">(May 26 2021 at 19:29)</a>:</h4>
<p>there are some clear stories about the problems that arise in the absence of async-drop;</p>



<a name="240378160"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378160" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378160">(May 26 2021 at 19:29)</a>:</h4>
<p>I see a few ways to approach solving them</p>



<a name="240378162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378162">(May 26 2021 at 19:29)</a>:</h4>
<p>Should I then add to any code review I'm doing "well, you can solve this with AsyncDrop, but you have to account for it not being called, so you also have to implement XYZ"</p>



<a name="240378165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378165">(May 26 2021 at 19:30)</a>:</h4>
<p>one of them is to have an async drop method</p>



<a name="240378217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378217">(May 26 2021 at 19:30)</a>:</h4>
<p>I don't want to do that</p>



<a name="240378229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378229">(May 26 2021 at 19:30)</a>:</h4>
<p>another is have some way to designate a "close" method</p>



<a name="240378239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378239">(May 26 2021 at 19:30)</a>:</h4>
<p>I dont' think they're incompatible, either</p>



<a name="240378267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378267">(May 26 2021 at 19:30)</a>:</h4>
<p>either way, you also have to ask yourself about sync drop-- you can lint a lot of cases, but not all</p>



<a name="240378300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378300">(May 26 2021 at 19:30)</a>:</h4>
<p><span class="user-mention silent" data-user-id="204219">Matthias247</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/.22inline.22.20async.20fn.20in.20traits/near/240378162">said</a>:</p>
<blockquote>
<p>Should I then add to any code review I'm doing "well, you can solve this with AsyncDrop, but you have to account for it not being called, so you also have to implement XYZ"</p>
</blockquote>
<p>this is true regardless</p>



<a name="240378309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378309">(May 26 2021 at 19:30)</a>:</h4>
<p>it seems like an orthogonal problem to me</p>



<a name="240378351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378351">(May 26 2021 at 19:31)</a>:</h4>
<p>but this is not a useful way to have the debate</p>



<a name="240378369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378369">(May 26 2021 at 19:31)</a>:</h4>
<p>a useful one is to write up the stories that tell me how you make the status quo better</p>



<a name="240378415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378415">(May 26 2021 at 19:31)</a>:</h4>
<p>and/or help critique the stories by shwing some of their flaws</p>



<a name="240378450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378450">(May 26 2021 at 19:32)</a>:</h4>
<p>(once they exist to be critiqued)</p>



<a name="240378518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378518">(May 26 2021 at 19:32)</a>:</h4>
<p>sync drop is very different. It will work unless something is leaked (and that is rather hard to do with rust). async drop will not work if someone uses functions that are described as best practices by the working group and ecosystem</p>



<a name="240378727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240378727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240378727">(May 26 2021 at 19:34)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I'm still confused by this, I've written up thousands of lines of text around this - in my free time. A lot of this coming out of real experience building async applications, and doing code reviews for multiple teams using this.  What is the issue here? Discoverability? The fact that its not in the newly endorsed "async wg format"?</p>



<a name="240379272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240379272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240379272">(May 26 2021 at 19:38)</a>:</h4>
<p>just two very primitive examples:</p>
<ul>
<li>You can't use <code>AsyncDrop</code> to abort any kind of transaction (e.g. a database transaction) in an async fashion if if someone uses <code>select!</code> with a timeout on the database. It will not run. </li>
<li>You can't use <code>AsyncDrop</code> to flush a buffered writer (e.g. around a file) if whatever is using the writer is inside a <code>select!</code> block. It will not run.</li>
</ul>



<a name="240380224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240380224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240380224">(May 26 2021 at 19:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="204219">Matthias247</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/.22inline.22.20async.20fn.20in.20traits/near/240378518">said</a>:</p>
<blockquote>
<p>sync drop is very different. It will work unless something is leaked (and that is rather hard to do with rust). async drop will not work if someone uses functions that are described as best practices by the working group and ecosystem</p>
</blockquote>
<p>you're making a lot of strong statements here :)</p>



<a name="240380500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240380500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240380500">(May 26 2021 at 19:46)</a>:</h4>
<p>I'm interested in working through those examples in detail to understand where they go wrong and if there aren't things we can change to fix it.</p>



<a name="240380623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240380623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240380623">(May 26 2021 at 19:47)</a>:</h4>
<p>Mostly I'm trying to work backwards from the problems that have been described to me -- for example <a href="https://rust-lang.github.io/wg-async-foundations/vision/status_quo/alan_finds_database_drops_hard.html">this story about dropping database handles</a>. Some reliably way to close async handles has been raised in virtually every conversation about async that I have had.</p>



<a name="240380725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240380725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240380725">(May 26 2021 at 19:48)</a>:</h4>
<p>In any case, those are helpful examples, thanks!</p>



<a name="240380996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240380996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240380996">(May 26 2021 at 19:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/async.20drop/near/240380224">said</a>:</p>
<blockquote>
<p>you're making a lot of strong statements here :)</p>
</blockquote>
<p>In particular, it feels like you're assuming specific aspects of the design. I'd like to understand that better.</p>



<a name="240381038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381038">(May 26 2021 at 19:50)</a>:</h4>
<p>Maybe these are fundamental constraints, or maybe they're specific to aspects of how select and cancellation work-- I can't quite tell.</p>



<a name="240381068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381068">(May 26 2021 at 19:50)</a>:</h4>
<p>It <em>sounds</em> like you're saying -- select drops the future synchronously -- therefore async drop can't work. But is it more than that?</p>



<a name="240381125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381125">(May 26 2021 at 19:51)</a>:</h4>
<p>yes, it's that</p>



<a name="240381151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381151">(May 26 2021 at 19:51)</a>:</h4>
<p>The fact that select cancels futures aggressively is itself a source of bugs independently of async drop</p>



<a name="240381172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381172">(May 26 2021 at 19:51)</a>:</h4>
<p>unless you change <code>select!</code> and all future combinators regarding not doing that, it won't work</p>



<a name="240381206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381206">(May 26 2021 at 19:51)</a>:</h4>
<p>but as a library author, you don#t know. You can't assume anything on how it is used</p>



<a name="240381253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381253">(May 26 2021 at 19:52)</a>:</h4>
<p>e.g., <a href="https://rust-lang.github.io/wg-async-foundations/vision/status_quo/alan_builds_a_cache.html">Alan tries to cache requests</a>, or <a href="https://rust-lang.github.io/wg-async-foundations/vision/status_quo/barbara_gets_burned_by_select.html">Barbara gets burned by select</a></p>



<a name="240381283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381283">(May 26 2021 at 19:52)</a>:</h4>
<p>so if you use <code>AsyncDrop</code> and someone uses your library function with <code>select!</code> - it's presumably still the libraries fault, not the users one</p>



<a name="240381332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381332">(May 26 2021 at 19:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="204219">Matthias247</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/async.20drop/near/240381172">said</a>:</p>
<blockquote>
<p>unless you change <code>select!</code> and all future combinators regarding not doing that, it won't work</p>
</blockquote>
<p>this seems correct-- synchronous drop will remain a possibility, unless we try to rule it out</p>



<a name="240381376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381376">(May 26 2021 at 19:53)</a>:</h4>
<p>these seem like orthogonal problems to me in some sense</p>



<a name="240381398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381398">(May 26 2021 at 19:53)</a>:</h4>
<ul>
<li>some things get dropped synchronously which shouldn't</li>
</ul>



<a name="240381446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381446">(May 26 2021 at 19:53)</a>:</h4>
<ul>
<li>we don't have an async equivalent of "drop"-- i.e., a way to cleanup resources conveniently and silently -- which introduces a disparity between sync and async code</li>
</ul>



<a name="240381448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381448">(May 26 2021 at 19:53)</a>:</h4>
<p>and that's the same I tried to tell above: I can't recommend anyone in the future to use <code>AsyncDrop</code> without understanding those scenarios. And I really really really would like not to talk about it. async rust is already complicated enough</p>



<a name="240381457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381457">(May 26 2021 at 19:53)</a>:</h4>
<p>I'd probably add third one:</p>



<a name="240381561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381561">(May 26 2021 at 19:54)</a>:</h4>
<ul>
<li>for both sync and async code, there is sometimes a problem that <code>Drop</code> doesn't fit, e.g. because there's more than one way to drop, or because you really want parameters to do cleanup (consider freeing a box and knowing how big its contents are)</li>
</ul>



<a name="240381598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381598">(May 26 2021 at 19:54)</a>:</h4>
<p>Sure. It's just that you're running really fast to a conclusion.</p>



<a name="240381639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381639">(May 26 2021 at 19:54)</a>:</h4>
<p>I'm not saying you're wrong, I'm just saying I want to take some time and explore and document the space.</p>



<a name="240381641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381641">(May 26 2021 at 19:54)</a>:</h4>
<p>sure, this is true - not everything can and should be solved with <code>Drop</code></p>



<a name="240381687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381687">(May 26 2021 at 19:54)</a>:</h4>
<p>I'm also not afraid to make big changes if we have to</p>



<a name="240381712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381712">(May 26 2021 at 19:55)</a>:</h4>
<p>Though of course we have to be very careful in how we manage that</p>



<a name="240381724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381724">(May 26 2021 at 19:55)</a>:</h4>
<p>But for solutions which can be  solved by it, offering a solution which only works depending on how others use your code does not seem a feasible way forward for me</p>



<a name="240381771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381771">(May 26 2021 at 19:55)</a>:</h4>
<p>I think there's a chance there are combinations you've not considered, or that there are things you considered immutable which are not.</p>



<a name="240381784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381784">(May 26 2021 at 19:55)</a>:</h4>
<p>As it happens It hink you're willing to consider big changes too :)</p>



<a name="240381848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381848">(May 26 2021 at 19:56)</a>:</h4>
<p>(I've seen you're our RFC on "must poll" futures, for example, and I'm thinking about that as a direction to consider)</p>



<a name="240381881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381881">(May 26 2021 at 19:56)</a>:</h4>
<p>I've considered a lot. I've written about this topic for 3 years now! And I've offered solutions for it</p>



<a name="240381889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381889">(May 26 2021 at 19:56)</a>:</h4>
<p>yes, that doc</p>



<a name="240381965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381965">(May 26 2021 at 19:56)</a>:</h4>
<p>And I'm at this point mainly a bit said why the discussion always goes back to the base points and I feel like I'm kind of writing into a void</p>



<a name="240381983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240381983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean McArthur <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240381983">(May 26 2021 at 19:56)</a>:</h4>
<p>It'd be interesting if async drop _could_ make <code>select!</code> and friends work. Like, if dropping that future means it recursively calls async drop, then maybe the resources inside the future could clean up correctly...</p>



<a name="240382020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240382020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240382020">(May 26 2021 at 19:57)</a>:</h4>
<p>it seems clear that if we added async drop, we'd have to rewrite our combinators to work with it</p>



<a name="240382062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240382062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240382062">(May 26 2021 at 19:57)</a>:</h4>
<p>how we manage the sync drop case is an interesting question, yes, but it really does seem orthogonal-- like, those bugs are there</p>



<a name="240382085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240382085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240382085">(May 26 2021 at 19:57)</a>:</h4>
<p><span class="user-mention" data-user-id="243965">@Sean McArthur</span> Sure, we can rewrite selected combinators to call async drop. But there's no guarantee you will catch all of them</p>



<a name="240382127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240382127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean McArthur <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240382127">(May 26 2021 at 19:58)</a>:</h4>
<p>I don't mean manually.</p>



<a name="240382220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240382220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240382220">(May 26 2021 at 19:58)</a>:</h4>
<p>but the combinators are all manual state machines :)  Look through <code>futurs-rs</code> and the bazillions of those</p>



<a name="240382299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240382299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean McArthur <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240382299">(May 26 2021 at 19:59)</a>:</h4>
<p>yes of course</p>



<a name="240382352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240382352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean McArthur <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240382352">(May 26 2021 at 19:59)</a>:</h4>
<p>I'm just tossing out there that'd be interesting if async-drop could be automatically applied to them all, the same way sync drop can be.</p>



<a name="240382453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240382453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240382453">(May 26 2021 at 20:00)</a>:</h4>
<p>I am pretty sure all of those combinators are going to get rewritten many times over the next few years :)</p>



<a name="240382539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240382539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240382539">(May 26 2021 at 20:00)</a>:</h4>
<p>That thought doesn't bother me nearly as much as not building a foundation for async rust that feels "just as nice" as sync rust</p>



<a name="240382692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240382692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240382692">(May 26 2021 at 20:01)</a>:</h4>
<p>But I agree that if library authors have to defend against sync drop <em>in practice</em> -- e.g., because we are not able to effectively deploy lints or other mechanisms that mean that sync drop doesn't occur -- then this goal will not be achieved.</p>



<a name="240382711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240382711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240382711">(May 26 2021 at 20:01)</a>:</h4>
<p>I think that's true regardless of whether we add async drop, however</p>



<a name="240382719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240382719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240382719">(May 26 2021 at 20:01)</a>:</h4>
<p>well maybe, maybe not. Realisitically they should have been dropped with <code>async fn</code>, because 95% of them can be replaced with either those or just <code>select!/join!</code>. But since the APIs where compatible, they have been kept arround. And I thinkt the same would happen in the future, unless APIs would fail to compile. You still have APIs around which have futures 0.1 assumptions and people stumble on them and use them</p>



<a name="240382746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240382746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240382746">(May 26 2021 at 20:02)</a>:</h4>
<p>So the real question is: how can we help make that transition</p>



<a name="240383841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240383841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240383841">(May 26 2021 at 20:09)</a>:</h4>
<p>The "must run to completion" doc has a story for transitioning. I agree it's not the prettiest one, but I still couldn't find a better one unless people are ok without strong guarantees.</p>



<a name="240383939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20drop/near/240383939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20drop.html#240383939">(May 26 2021 at 20:09)</a>:</h4>
<p>But I feel like we shouldn't be ok without it, Rust in general is all about strong guarantees, and so this seems like a weak spot to me.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>